package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bean.ResponseBean;
import com.dao.MajorDao;
import com.pojo.Major;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MajorService extends ServiceImpl<MajorDao , Major> {

    /**
     * 分页查询专业
     * @param page
     * @param limit
     * @return
     */
    public IPage majors(Integer page , Integer limit,String key,String mtid){

        QueryWrapper query = new QueryWrapper();
        if(StringUtil.isNotNull(key)){
            query.like("mjname",key) ;
        }
        if(StringUtil.isNotNull(mtid)) {
            query.eq("mtid" , mtid) ;
        }
        IPage iPage = page(new Page<Major>(page , limit),query) ;
        return iPage ;
    }
}
